package leetcode.median;

import leetcode.offer.NumWays;

/**
 * ClassName: $739_DailyTemperatures
 * Description:
 * date: 2022-02-19 12:00
 *
 * @author liyifan
 */
public class $739_DailyTemperatures {
    public int[] dailyTemperatures(int[] temperatures) {
        int len = temperatures.length;
        int[] res = new int[len];
        for (int i = len - 2;i >= 0;i--) {
            for (int j = i + 1;j < len;j += res[j]) {
                if (temperatures[j] > temperatures[i]) {
                    res[i] = j - i;
                    break;
                } else if(res[j] == 0){
                    res[i] = 0;
                    break;
                }
            }
        }
        return res;
    }
}
